package edu.gznu.ics.fast.pulsar.controller.prestoacc.taskCtrlController.computeTask;

import edu.gznu.ics.fast.pulsar.model.po.prestoacc.task.computeTask.parameter.TaskParameterPO;
import edu.gznu.ics.fast.pulsar.model.vo.prestoacc.task.computeTask.parameter.EditTaskParaVO;
import edu.gznu.ics.fast.pulsar.model.vo.user.TdUserVO;
import edu.gznu.ics.fast.pulsar.model.vo.web.QueryCommandVO;
import edu.gznu.ics.fast.pulsar.model.vo.web.TaskIdQueryVO;
import edu.gznu.ics.fast.pulsar.model.vo.web.UserParaTree;
import edu.gznu.ics.fast.pulsar.service.prestoacc.taskService.ComputeTask.ComputeParameterService;
import edu.gznu.ics.fast.pulsar.service.prestoacc.taskService.ComputeTask.ComputeTaskService;
import edu.gznu.ics.fast.pulsar.service.prestoacc.taskService.ComputeTask.StartComputeTaskService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by fei-zyx on 2016/10/11.
 */

@Controller
@RequestMapping("/para")
public class ComputeParameterController {
    @Autowired
    ComputeTaskService computeTaskService;
    @Autowired
    ComputeParameterService computeParameterService;
    @Autowired
    StartComputeTaskService startComputeTaskService;

    @RequestMapping(value = {"/showTaskList"})
    @ResponseBody
    public List<UserParaTree> showTaskListByUserId(@ModelAttribute @Valid TdUserVO tdUserVO, BindingResult result) {

        return computeParameterService.findAllTaskIdByUserName(SecurityUtils.getSubject().getPrincipal().toString());
        //  computeTaskService.addNewTaskList();

    }

    @RequestMapping(value = {"/addPara"})
    public String addComputeTaskPara(@ModelAttribute @Valid EditTaskParaVO editTaskParaVO, BindingResult result) {
        //omputeParameterService.addTaskParaByTaskId();
        return "";
    }

    @RequestMapping(value = {"/editPara"})
    public String editComputeTaskPara(@ModelAttribute @Valid EditTaskParaVO editTaskParaVO, BindingResult result) {
        computeParameterService.modifyTaskParaByTaskId();
        return "";
    }

    @RequestMapping(value = {"/delPara"})
    public String delComputeTaskPara(@ModelAttribute @Valid EditTaskParaVO editTaskParaVO, BindingResult result) {
        // computeParameterService.delaskParaByTaskId();
        return "";
    }

    @RequestMapping(value = {"/showParaByUserId"})
    @ResponseBody
    public List<TaskParameterPO> showParaList(@RequestBody List<TaskIdQueryVO> taskIdQueryVOs) {
        return computeParameterService.findTaskParaByTaskId(taskIdQueryVOs.get(0));

    }
}
